package com.designmode.singleton;

/**
 * 枚举实现单例
 *
 * @Author ifredomvip@gmail.com
 * @Date 2022/12/7 22:20
 */
public class SingletonEnum {

    public static void main(String[] args) {
        SingletonEnumClass instance = SingletonEnumClass.instance;
        SingletonEnumClass instance1 = SingletonEnumClass.instance;
        System.out.println(instance == instance1);

    }
}


enum SingletonEnumClass {
    /**
     * 实例
     */
    instance;

    /**
     * 说
     */
    void say() {
        System.out.println("say ok");
    }
}